//
//  PlusButton.swift
//  BKL_HealthProject
//
//  Created by gePengFei on 2018/7/27.
//  Copyright © 2018年 yunjing. All rights reserved.
//

import Foundation

typealias plusBtnCallBack = () -> ()

class PlusButton {
    
    var callBack :plusBtnCallBack?
    fileprivate lazy var plusButton :UIButton = {
        let btn = UIButton(type: .custom)
        btn.setImage(UIImage(named: "icon_reminder_add"), for: .normal)
       
        btn.addTarget(self, action: #selector(plusBtnClick), for: .touchUpInside)
        btn.isHidden = true
        return btn
    }()
    
    init(frame:CGRect) {
        plusButton.frame = frame
    }
    
    @objc private func plusBtnClick(){
        callBack?()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    public func showPlusBtn(){
        plusButton.isHidden = false
    }
    public func hiddenPlusBtn(){
        plusButton.isHidden = true
    }
    public func addToSuperView(){
        UIApplication.shared.keyWindow?.addSubview(plusButton)
    }
    public func removePlusBtn(){
        plusButton.removeFromSuperview()
    }
    public func isHidden() -> Bool {
        return plusButton.isHidden
    }
}
